<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品详情页</title>
	<!-- 引入我们的favicon首页图标 -->
	<link rel="shortcut icon" href="favicon.ico" />
	<link rel="stylesheet" type="text/css" href="css/login2.css">
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$.ajax({
			url:"${pageContext.request.contextPath}/type?method=findAll",
			type:"GET",
			dataType:"json",
			success:function(data){
				for(var i in data){
					var a = $("<a href='${pageContext.request.contextPath}/product?method=show&tid="+data[i].tid+"'>"+data[i].tname+"</a>");
					$("#goodsType").append(a);
				}
			},
			error:function(){
				alert("失败");
			}
		})
	})
	function tobuybypid(pid) {
		alert("/order?method=preView&pid="+pid)
		location.href="/order?method=preView&pid="+pid;
	}
</script>
</head>
<body>
<div id="top">
	<div id="topdiv">
            <span>
                <a href="index.jsp" id="a_top" target="_blank">Myshopping商城</a>
            </span>

		<span style="float:right">
           		<c:if test="${empty loginUser}">
					<a href="login.jsp" id="a_top">登录</a>
					<li>|</li>
					<a href="register.jsp" id="a_top">注册</a>
				</c:if>
       			<c:if test="${not empty loginUser}">
					<a href="user?method=selectUserByUid" id="a_top">${loginUser.username}</a>
					<li>|</li>
					<a href="user?method=logOut" id="a_top">注销</a>
					<li>|</li>
					<a href="order?method=show" id="a_top">我的订单</a>
					<li>|</li>
					<a href="address?method=show" id="a_top">地址管理</a>
				</c:if>
<%--                <li>|</li>--%>
<%--                <a href="" id="a_top">消息通知</a>--%>
                <a href="${pageContext.request.contextPath}/cart?method=show&uid=${loginUser.uid}" id="shorpcar">购物车</a>
            </span>
	</div>
</div>
<div id="second">
	<a href="index.jsp" id="seimg" style=" margin-top:23px;"><img id="logo" src="image/logo.png" width="119.5" height="59"/></a>
	<p id="goodsType">
		<!-- 根据ajax 回调函数 填写数据 到此id中 -->
	</p>
	<form class="form-inline pull-right" style="margin-top: 40px;margin-right: 10px;" action="/product?method=likeshow&" method="post">

		<div class="form-group">
			<input type="text" class="form-control" style="width: 400px" name="str" placeholder="搜索一下好东西...">
		</div>
		<button type="submit" class="btn btn-warning"><span class="glyphicon glyphicon-search"></span>&nbsp;&nbsp;搜索</button>
	</form>
</div>

    	<div style="margin: 0 auto;width: 90%;">
	   <ol class="breadcrumb">
		  <li><a href="index.jsp">MyShop商城</a></li>
		   <li><a href="/product?method=show&tid=${product.tid}" id="productName"></a></li>
		  <li class="active"><a href="/product?method=detail&pid=${product.tid}">${product.pname}</a></li>
	   </ol>
   </div>
   
	<div class="container">
		<div class="row">
		  <div class="col-xs-6 col-md-6">
		    <a href="#" class="thumbnail">
		      <img src="${pageContext.request.contextPath}/${product.pimage}"  style="width: 560px;height: 560px;"  alt="${product.pname}" />
		    </a>
		  </div>
		  <div class="col-xs-6 col-md-6">
		   	<div class="panel panel-default" style="height: 560px">
			  <div class="panel-heading">商品详情</div>
			  <div class="panel-body">
			    <h3>产品名称:<small>${product.pname}</small></h3>
			    <div style="margin-left: 10px;">
				    
				   <p>市场价格:&nbsp;&nbsp;&nbsp;<span class="text-danger" style="font-size: 15px;">${product.pprice}</span>&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-yen"></span></p>
				    <p>上市时间:&nbsp;&nbsp;&nbsp;${product.ptime}</p>
				     <p>热销指数:&nbsp;&nbsp;&nbsp;
						<c:forEach begin="1" end="${product.pstate}">
				        		<img src="image/star_red.gif" alt="star"/>
				        	</c:forEach>
					</p>
				    <p>详细介绍:</p>
				    <p>&nbsp;&nbsp;${product.pinfo }</p>
				    <a href="${pageContext.request.contextPath}/cart?method=create&pid=${product.pid}" class="btn btn-warning">加入购物车&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-shopping-cart"></span></a>&nbsp;&nbsp;&nbsp;
			    </div>
			  </div>
			</div>
		  </div>
		</div>
	</div>

<script type="text/javascript">
	$(document).ready(function(){
		$.ajax({
			url:"${pageContext.request.contextPath}/type?method=findTypeBypid&pid="+${product.pid},
			type:"GET",
			dataType:"json",
			success:function(type){
				var b=type.tname;
				$("#productName").append(b);
			},
			error:function(){
				alert("失败");
			}
		})
	})
</script>
</body>
</html>